package com.uraurora.crescent.tuple;

import com.sun.istack.internal.NotNull;
import com.uraurora.crescent.util.SeiIterables;

/**
 * 包含一个元素的元组
 * @author ：Sei
 * @param <T>
 */
public class Tuple1<T> extends AbstractTuple implements ITuple {

    private static final int SIZE = 1;

    private Tuple1(Object[] values){
        super(values);
    }

    public static <T> Tuple1<T> of(T t){
        Object[] objects = {t};
        return new Tuple1<>(objects);
    }

    static <T> Tuple1<T> of(@NotNull Iterable<?> iterable){
        Object[] obj = SeiIterables.toArray(iterable, SIZE);
        return new Tuple1<>(obj);
    }


}
